package shuati;

/**
 * @date:2022/9/25
 * @author:CqLtd
 * @name:药房管理
 */
import java.util.Scanner;

public class p3 {

    public static void main(String[] args) {
        int m,n,i,r,sum=0;
        Scanner sc = new Scanner(System.in);
        m=sc.nextInt();
        n=sc.nextInt();

        for(i=1;i<=n;i++)
        {
            r=sc.nextInt();
            if(m>=r)
            {
                m-=r;
            }
            else
            {
                sum++;
            }
        }

        System.out.println(sum);

    }
}